const User = require('../../models/user')

module.exports = (req,res) => {
  const userId = req.body.userId
  User.findById({_id:userId},(err,userDoc) => {
    userDoc.last_modified_time = new Date
    userDoc.logout_time = new Date
    User.findByIdAndUpdate({_id:userId},userDoc,(err) => {
      if (err) {
        res.status(500).json({
          err_code: 500,
          message:err.message
        })
      }
      res.status(200).json({
        err_code: 0,
        message:'退出登录成功，下次再见。'
      })
    })
  })
}